﻿using Basic.FlowCollect;
using Basic.FlowModel.DB;
using Basic.FlowRemoteModel.EventTemplate.Model;
using Basic.FlowService.Interface;
using WeDonekRpc.Client;
using WeDonekRpc.Model;

namespace Basic.FlowService.lmpl
{
    internal class FlowEventInterService : IFlowEventInterService
    {
        private readonly IEventTemplateCollect _Service;

        public FlowEventInterService ( IEventTemplateCollect service )
        {
            this._Service = service;
        }
        public bool Disable ( long id )
        {
            DBFlowEventTemplate sour = this._Service.Get(id);
            return this._Service.Disable(sour);
        }
        public bool Enable ( long id )
        {
            DBFlowEventTemplate sour = this._Service.Get(id);
            return this._Service.Enable(sour);
        }
        public EventInterItem[] GetItems ()
        {
            return this._Service.Gets<EventInterItem>();
        }
        public long Add ( EventTemplateAdd data )
        {
            return this._Service.Add(data);
        }
        public bool Set ( long id, EventTemplateSet data )
        {
            DBFlowEventTemplate sour = this._Service.Get(id);
            return this._Service.Set(sour, data);
        }
        public PagingResult<EventInter> Query ( InterQueryParam query, IBasicPage paging )
        {
            EventInter[] result = this._Service.Query<EventInter>(query, paging, out int count);
            return new PagingResult<EventInter>(result, count);
        }
        public EventInterDto Get ( long id )
        {
            DBFlowEventTemplate sour = this._Service.Get(id);
            return sour.ConvertMap<DBFlowEventTemplate, EventInterDto>();
        }
        public void Delete ( long id )
        {
            DBFlowEventTemplate sour = this._Service.Get(id);
            this._Service.Delete(sour);
        }

        public Dictionary<long, string> GetNames ( long[] ids )
        {
            return this._Service.GetNames(ids);
        }
    }
}
